<?php 
  /*echo"<pre>";
  print_r($this->data);
  echo"</pre>";*/
?>
<script type="text/javascript">
  jQuery(function($){
    $('#chk_st_member').click(function(){
      var l = $("#chk_st_member:checked").val();

      if(l == 'on'){
        $("#st_member").val(1);
      }  
      else{
        $("#st_member").val('0');
      }    
    });
  });   

  jQuery(function($){
    $('#re_password').blur(function(){
      if($('#ds_password').val()){
        var n = $("input:checked").val();
        var iTotalChar = 0;
        var tTotalChar = 6;

        iTotalChar = $('#ds_password').val();

        if(n != 1){
          if($('#ds_password').val() != $('#re_password').val()){
            $("#verify").show();
            
            $("#div_verify").text("As senhas estão diferente");
          }  
          else if($('#ds_password').val().length < tTotalChar){
            $("#verify").show();  
            
            $("#div_verify").text("Valor do campo 'Senha' dever tem no mínimo " + tTotalChar + " caractéres!");
          }
          else if($('#re_password').val().length < tTotalChar){
            $("#verify").show();
              
            $("#div_verify").text("Valor do campo 'Repetir Senha' dever tem no mínimo " + tTotalChar + " caractéres!");
          }
          else{
            $("#verify").hide();
          }  
        } 
      }
      else{
        $("#verify").hide();
      }
    });
  }); 

  jQuery(function($){
    $('#form1').submit(function(){
      if($('#idOrganization').val() == ""){
        $("#verify").show();

        $("#div_verify").text("Selecione uma Organização");

        return false;
      }

      if($('#idProfile').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Selecione um Perfil de Acesso");
        
        return false;
      }

      if($('#ds_member').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Nome do Usuário é obrigatório.");
        
        return false;
      }

      if($('#ds_email').val() == ""){
        $("#verify").show();
        $("#div_verify").text("E-mail é obrigatório.");
          
        return false;
      }

      if($('#ds_login').val() == ""){
        $("#verify").show();
        $("#div_verify").text("Login é obrigatório.");
        
        return false;
      }
    });
  });
</script>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="margin-top: 30px; margin-bottom: 30px; padding-left: 30px; padding-right: 30px;">
  <tr>
    <td style="vertical-align: top;">
      <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
			  <tr>
			    <td class="label_page" width="120" align="center">
			      <span>Atualizar Usuário</span>
			    </td>
			    <td>&nbsp;</td>
			  </tr>
			  <tr>
			    <td align="center" colspan="2" class="content_page">
			      <form name="form1" id="form1" method="POST" action="<?php echo $this->baseUrl?>/members/update-member">
			        <table border="0" cellpadding="0" cellspacing="4" align="left" width="100%">
			          <tr id="verify">
			            <td align="center" colspan="2">
			              <div id="div_verify" style="padding: 10px;"></div>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">Organização:</td>
			            <td align="left">
			              <select name="idOrganization" id="idOrganization" class="select">
			                <?php 
			                  if($this->data->idOrganization){?>
			                    <option value="<?php echo $this->data->idOrganization?>"><?php echo $this->data->ds_organization?></option>
			                  	<?php
			                  }
			                  else{?>
			                    <option value="">Selecione</option>
			                  	<?php
			                  }
			                  
			                  foreach($this->organizations as $orgs){
			                    $orgs = (object)$orgs;
			                    
			                    if($orgs->idOrganization != $this->data->idOrganization){?>
			                      <option value="<?php echo $orgs->idOrganization?>"><?php echo $orgs->ds_organization?></option>
			                      <?php
			                    }  
			                  }
			                ?>
			              </select>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
			          <tr>
			            <td align="right" class="label">Perfil de acesso:</td>
			            <td align="left">
			              <select name="idProfile" id="idProfile" class="select">
			                <?php 
			                  if($this->data->idProfile){?>
			                  	<option value="<?php echo $this->data->idProfile?>"><?php echo $this->data->ds_profile?></option>
			                  	<?php
			                  }
			                  else{?>
			                  	<option value="">Selecione</option>
			                  	<?php
			                  }
			                  
			                  foreach($this->profiles as $profs){
			                    $profs = (object)$profs;
			                    
			                    if($profs->idProfile != $this->data->idOrganization){?>
			                      <option value="<?php echo $profs->idProfile?>"><?php echo utf8_encode($profs->ds_profile)?></option>
			                      <?php
			                    }  
			                  }
			                ?>
			              </select>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">Nome do Usuário:</td>
			            <td align="left">
			              <input type="text" name="ds_member" id="ds_member" class="text_field" size="40" maxlength="100" value="<?php echo $this->data->ds_member ? $this->data->ds_member : '';?>"/>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">E-mail:</td>
			            <td align="left">
			              <input type="text" name="ds_email" id="ds_email" class="text_field" size="40" maxlength="120" value="<?php echo $this->data->ds_email ? $this->data->ds_email : '';?>" readonly="readonly"/>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">Login:</td>
			            <td align="left">
			              <input type="text" name="ds_login" id="ds_login" class="text_field" size="40" maxlength="40" value="<?php echo $this->data->ds_login ? $this->data->ds_login : '';?>" readonly="readonly"/>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">Inserir Senha Padrão:</td>
			            <td align="left">
			              <input type="checkbox" name="pwd_default" id="pwd_default" value="1"/>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">Senha:</td>
			            <td align="left">
			              <input type="password" name="ds_password" id="ds_password" class="text_field" size="40" maxlength="15"/>
			              <b style="color: #FF0000">*</b>
			              <span style="font-size: 11px; color: #999;">- Somente Letras e números, no minimo 6 e no máximo 15 caracteres.</span>
			            </td>
			          </tr>
			          
			          <tr id="row_repass" class="label">
			            <td align="right">Repetir Senha:</td>
			            <td align="left">
			              <input type="password" name="re_password" id="re_password" class="text_field" size="40" maxlength="15"/>
			              <b style="color: #FF0000">*</b>
			            </td>
			          </tr>
			          
			          <tr>
			            <td align="right" class="label">Ativado:</td>
			            <td align="left">
			              <?php 
			                if($this->data->st_member == 1){
			                  $checked = "checked='checked'";
			                  
			                  $value = "value = '{$this->data->st_member}'";
			                }
			                else{
			                  $checked = "";
			                  
			                  $value = "";
			                }
			              ?>
			              <input type="checkbox" name="chk_st_member" id="chk_st_member" <?php echo $checked?>/>
			              <input type="hidden" name="st_member" id="st_member" value="1"/>
			            </td>
			          </tr>
			          
			          <tr>
			            <td colspan="2" height="15">&nbsp;</td>
			          </tr>
			          
			          <tr>
			            <td colspan="2" align="center">
			              <input type="submit" id="btn_submit" value="Salvar" class="button"/>
			            </td>
			          </tr>
			        </table>
			      </form>  
			    </td>
			  </tr>
			  <tr>
			    <td class="label" colspan="2">
			      (<b style="color: #FF0000">*</b>) - Campos Obrigatórios.
			    </td>
			  </tr>
			</table>
		</td>
	</tr>		  
</table>